<?php
    session_start();
    
    if($_SERVER['REQUEST_METHOD'] == "POST") {
        include("conexion.php");
        $conn = new mysqli($dbhost, $dbuser, $dbpass, $db);
        
        $user = strtoupper(str_replace("'", "", $_POST["txtNombUsua"]));
        $pass = strtoupper(str_replace("'", "", $_POST["txtNombPass"]));
        
        $tabla = $conn->query("SELECT NombComp FROM usuarios WHERE NombUsua = '{$user}' AND NombPass = '{$pass}' AND NumeEsta = 1");

        $strSalida = "";
        
        if ($tabla->num_rows > 0)
        {
        	$fila = $tabla->fetch_array();
            $_SESSION['is_logged_in'] = 1;
            $_SESSION['NombUsua'] = $fila['NombComp'];
            
            $strSalida = "1@".$_SESSION['NombUsua']."#4";
        }
        else
        	$strSalida = "login_error";
        
        $tabla->free();
        $conn->close();
        
        echo $strSalida;
    }
?>